#include <stdio.h>
#include <string.h>
int main()
{
    char m[60];
    int n,i,j,t1,t2,t3,t4;
    scanf("%d",&n);
    for (j=0;j<n;j++)
    {
        scanf("%s",m);
        if (strlen(m)<8||strlen(m)>16)printf("NO\n");
        else
        {
            t1=t2=t3=t4=0;
            for (i=0;i<strlen(m);i++)
            {
                if (m[i]>='0'&&m[i]<='9')t1=1;
                if (m[i]>='a'&&m[i]<='z')t2=1;
                if (m[i]>='A'&&m[i]<='Z')t3=1;
                if (m[i]=='~'||m[i]=='!'||m[i]=='@'||m[i]=='#'||m[i]

=='$'||m[i]=='%'||m[i]=='^')t4=1;
            }
            if (t1+t2+t3+t4>=3)printf("YES\n");
            else printf("NO\n");
        }
    }
    return 0;
}
